﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SY_Library
{
    public static class Strings
    {
        /// <summary>
        /// 获取枚举下标
        /// </summary>
        /// <typeparam name="T">枚举对象</typeparam>
        /// <param name="str">对应的字符串</param>
        /// <returns>指定对象的下标</returns>
        public static int GetEnumIndex<T>(this string str) where T : Enum
            => typeof(T).GetEnumNames().ToList().IndexOf(str);
    }
}
